package cn.net.cfss.fgbp.provider.console.biz;

import cn.net.cfss.fgbp.api.console.dto.SysRoleAppDto;
import cn.net.cfss.fgbp.api.console.vo.SysRoleAppVo;
import cn.net.cfss.fgbp.base.common.biz.BaseBiz;
import cn.net.cfss.fgbp.provider.console.dao.SysRoleAppDtoMapper;
import cn.net.cfss.fgbp.provider.console.utils.FgbpIdUtil;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;

/**
 * @author oygq
 * @title: RoleAppDtoBiz
 * @description: TODO
 * @date 2019/4/3 11:04
 */
@Service
public class SysRoleAppDtoBiz extends BaseBiz<SysRoleAppDtoMapper, SysRoleAppDto> {

    @Transactional
    public void deleteBatch(Long[] roleAppIds) {
        mapper.deleteBatch(roleAppIds);
    }

    @Transactional
    public void insertBatch(SysRoleAppVo vo){
        for(Long appId : vo.getAppIds()){
            vo.setId(FgbpIdUtil.generateId());
            vo.setAppId(appId);
            vo.setRoleId(vo.getRoleId());
            insert(vo);
        }
    }

    @Transactional
    public void updateBatch(SysRoleAppVo vo){
        for(Long appId : vo.getAppIds()){
            vo.setId(FgbpIdUtil.generateId());
            vo.setAppId(appId);
            vo.setRoleId(vo.getRoleId());
            insert(vo);
        }
    }
}
